from queue import LifoQueue

lifo_queue = LifoQueue()

for i in range(4):
    lifo_queue.put(i)

while not lifo_queue.empty():
    print(lifo_queue.get())